// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2005-6-30

#ifndef __TM_SHUTDOWNROOM_H_SERVER_SVR_MAIN__
#define __TM_SHUTDOWNROOM_H_SERVER_SVR_MAIN__

#pragma once

#include <common/svr_base/base_timer.h>
#include <common/svr_base/svr_asyncobj.h>

namespace JoyServer
{

class CJoyMainServer;
class CJoyAsyncQueue;

class CJoyTmShutdownRoom : public CJoyTimerObject
{
public:
    class CShutdownInfo
    {
    public:
        DWORD   m_start;
        DWORD   m_delay;
        DWORD   m_lastNote;
        DWORD   m_noteDelay;
        UINT    m_roomId;
        CString m_note;
    };
    CJoyMainServer* m_server;
    CJoyCriticalSection m_shutdownLock;
    CList<CShutdownInfo*>    m_shutdownList;

    virtual void OnExecute();
public:
    CJoyTmShutdownRoom();
    virtual ~CJoyTmShutdownRoom();

    virtual bool Create(CJoyMainServer* pServer);
    virtual void Destroy();

    CShutdownInfo* PeekInfo();
    void AddInfo(CShutdownInfo* pInfo);
    void SendInfo(CShutdownInfo* pInfo);
    void ClearInfo(CShutdownInfo* pInfo);

    void AddRoom(UINT roomId, UINT delay, const CString& note, DWORD noteDelay = 60*1000);
};

} // namespace JoyServer

#endif  // __TM_SHUTDOWNROOM_H_SERVER_SVR_MAIN__